<template>
  <div>
    <table-ext :columns="columns" :searchForm="searchForm" :config="config" ref="tableExt">
    </table-ext>
  </div>
</template>
<script>
  import TableExt from '@/components/common/table-ext/table-ext.vue';
  export default {
    // 引入自定义表格组件
    components: {
      'table-ext': TableExt
    },
    data() {
      return {
        config: { // 页面共通配置
          title: '工厂管理', //页面标题
          isPage: true, //是否分页
          isNo: false, //是否显示序号
          // align:'center',
          selection: false, //是否显示复选框
          crudMapping: { // CRUD方法
            query: {
              url: this.lib.config.host.masterData + '/system/factoryMgt/factorys/query',
            }
            // delete: {
            //   url: this.lib.config.host.masterData + '/system/expert/delete'
            // }
          }
        },
        // 查询表单配置
        searchForm: [{
          //显示标签
          label: '工厂编码',
          //数据字段
          key: 'factoryCode',
          //标签类型
          type: 'input'
        }, {
          label: 'ERP编码',
          key: 'factoryErpCode',
          type: 'input'
        }, {
          label: '工厂名称',
          key: 'factoryName',
          type: 'input'
        }],
        // 表格列定义
        columns: [{
          width: '200',
          label: '工厂编码', // 表格header
          render: (createElement, params) => { // 动态渲染，click事件示例
            let _this = this;
            return createElement('div', {}, [createElement('a', {
              style: {
                color: '#409EFF',
                cursor: 'pointer'
              },
              on: {
                click() {
                  _this.setCurrent(params.row.id);
                }
              }
            }, params.row.factoryCode)]);
          }
        }, {
          label: 'ERP编码',
          key: 'factoryErpCode'
        }, {
          label: '简称',
          width:'240',
          key: 'factoryName'
        }, {
          label: '全称',
           width:'240',
          key: 'factoryNameFull'
        }, {
          label: '地址',
           width:'400',
          key: 'factoryAdd'
        }, {
          label: '最后修改时间',
           width:'160',
          key: 'lastModifyTime'
        }]
      };
    },
    methods: {
      //点击编码 跳转到新页面
      setCurrent(id) {
        window.open('/FactoryMaterial?factoryId=' + id)
      }
    }
  }

</script>
